package com.xiaohudie.CompressPicture;

import net.coobird.thumbnailator.Thumbnails;

import java.io.File;
import java.io.IOException;

/**
 * @Author xiao hu die
 * @Date 2022/2/28 14:59
 * @Version 1.0
 */
public class Test04 {
 public static void main(String[] args) {
  operateByPer("D\\潘晓阳原图.png","D:\\png\\1001.png",50.00);
 }
 public static boolean operateByPer(String inSrc, String outSrc, double percent){
  boolean flag = false;

  Thumbnails.Builder<File> builder = Thumbnails.of(inSrc);
  builder.scale(percent);
  try {
   try {
    builder.toFile(outSrc);
   } catch (IOException e) {
    e.printStackTrace();
   }
   flag = true;
  } catch (Exception e) {
   e.printStackTrace();
  }
  return flag;
 }
}
